package serverDB;


import java.util.Set;

import org.hibernate.Session;
/**
 * managing the interactions with database for the table File
 * @author ran
 *
 */
public class FileManager {
	private Session session = null;
	 public FileManager(Session session) {
	  if(session == null)
	    throw new 
	      RuntimeException("Invalid session object.");
	  this.session = session;
	 }
	 public void save(File file){
	 	session.save(file);
	 }
	 public void update(File file){
	 	session.update(file);
	 }
	 public void delete(File file) {
	 	session.delete(file);
	 	Set<Box> boxes = file.getBoxes();
	 	for (Box b : boxes){
	 		b.removeFile(file);
	 	}
	 }

}
